<?php
    $url = new Url();
?>
<script type="text/javascript">
    function ajaxAddBannChat(){
        id='<?php echo $_GET['id']; ?>';
        from_date=$("#from_date").val();
        to_date=$("#to_date").val();
        var strUrl = "<?php echo $url->createUrl("bannchat/ajaxAddBannChat") ?>";
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {
                id:id,
                from_date:from_date,
                to_date:to_date
                
            },
            success: function(msg){
                if(msg == 1){
                    alert('Thêm mới thành công');
                    window.location = '<?php echo $url->createUrl("bannchat/index")?>';
                }else{
                    $("#show_error").html(msg);
                }
            },
            beforeSend:function(){
                $("#button_save").attr("disabled","disabled");
            },
            complete:function(){
                $("#button_save").removeAttr("disabled"); 
            }            
        });
    }
</script>
<div class="main clearfix">
    <div class="box clearfix bottom30">
        <ul class="form4">

            <li class="clearfix"><label><strong>Username </strong>:</label>
                <div class="filltext">
                    <input value="<?php echo $_GET['username'] ?>" type="text" style="width: 170px;" id="username"/>
                </div>
            </li>
            <li class="clearfix"><label><strong>Từ ngày </strong>:</label>
                <div class="filltext">
                    <?php
                        $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'name' => 'from_date',
                        'id' => 'from_date',
                        'value' => $from_date,
                        // additional javascript options for the date picker plugin
                        'options' => array(
                        'showAnim' => 'fold',
                        'dateFormat' => 'dd-mm-yy',
                        'changeYear' => 'true',
                        'changeMonth' => 'true',
                        'showOn' => 'both',
                        'buttonText' => '...'
                        ),
                        'htmlOptions' => array(
                        'style' => 'width:170px',
                        'class' => 'form',
                        ),
                        ));
                    ?> 
                    &nbsp;đến ngày &nbsp; 
                    <?php
                        $this->widget('zii.widgets.jui.CJuiDatePicker', array(
                        'name' => 'to_date',
                        'id' => 'to_date',
                        'value' => $to_date,
                        // additional javascript options for the date picker plugin
                        'options' => array(
                        'showAnim' => 'fold',
                        'dateFormat' => 'dd-mm-yy',
                        'changeYear' => 'true',
                        'changeMonth' => 'true',
                        'showOn' => 'both',
                        'buttonText' => '...'
                        ),
                        'htmlOptions' => array(
                        'style' => 'width:170px',
                        'class' => 'form',
                        ),
                        ));
                    ?> 
                </div>
            </li>
            <li class="clearfix"><label>&nbsp;</label>
                <div class="filltext">
                    <input id="button_save" type="button" value=" Thêm mới " class="btn-bigblue" onclick="ajaxAddBannChat();"> 
                    &nbsp;
                    <input onclick="history.go(-1)" type="button" value=" Quay lại " class="btn-bigblue">
                </div>
            </li>
            <li class="clearfix"><label>&nbsp;</label>
                <div class="filltext" style="color: red;" id="show_error"></div>
            </li>
        </ul>

    </div>
</div>